package com.css.zfzx.sjcj.modules.hddcMainAFSvyRegion.repository;

import com.css.zfzx.sjcj.modules.hddcMainAFSvyRegion.repository.entity.HddcMainafsvyregionEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author zyb
 * @date 2020-12-14
 */
public interface HddcMainafsvyregionRepository extends JpaRepository<HddcMainafsvyregionEntity, String> {

    @Query(nativeQuery = true, value = "select * from hddc_Mainafsvyregion where is_valid !=0 and pro_name in :projectIds")
    List<HddcMainafsvyregionEntity> queryHddcMainafsvyregionsByProjectId(List<String> projectIds);

    @Query(nativeQuery = true, value = "select * from hddc_Mainafsvyregion where is_valid = '1'")
    List<HddcMainafsvyregionEntity> findAll();

    @Query(nativeQuery = true, value = "select * from hddc_Mainafsvyregion where task_name in :projectIds")
    List<HddcMainafsvyregionEntity> queryHddcMainafsvyregionsByTaskId(List<String> projectIds);

    @Query(nativeQuery = true, value = "select * from hddc_Mainafsvyregion where create_user = :createID and province = :provinceName and city =:cityName and area =:areaName")
    List<HddcMainafsvyregionEntity> queryHddcMainafsvyregionByCreateuser(String createID,String provinceName,String cityName,String areaName);

    @Modifying
    @Query(nativeQuery = true, value = "update hddc_Mainafsvyregion set is_valid = '0' where province = :provinceName and city =:cityName and area =:areaName and extends8 =:savefilename")
    void deleteFileData(String provinceName,String cityName,String areaName,String savefilename);
}
